package com.xxxx.servlet;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/*
 *  请求转发跳转
 *  可以让请求从服务端跳转到客服端(或跳转到指定的Servlet)
 *  
 * 	特点:
 * 		1. 服务器行为
 * 		2. 地址栏不发生改变
 * 		3. 从始至终只有一个请求
 * 		4. request数据可以共享
 */


@WebServlet("/S3")
public class Servlet03请求转发 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//接受客户端请求的参数
		String uname = request.getParameter("uname");
		System.out.println("Servlet03 uname: "+uname);
		
		//请求转发跳转到Servlet04
		//request.getRequestDispatcher("S4").forward(request, response);
		
		//请求转发跳转到jsp页面
		//request.getRequestDispatcher("login.jsp").forward(request, response);
		
		//请求跳转到html页面
		request.getRequestDispatcher("login.html").forward(request, response);
	}
		
}
